package com.briup.web02.controller;

import com.briup.web02.entity.Student;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

@RestController
public class ParamController {

    @RequestMapping("simpleParam")
    public String simpleParam(String name,int age,@RequestParam(value = "groupName",required  =false,defaultValue = "豁牙牙幼儿园") String group){
        return "你好啊来自"+group+"的"+name+",听说你刚满"+age;
    }
    @RequestMapping("entityParam")
    public String entityParam(Student student){
        System.out.println(student);
        return "你好啊来自"+student.getGroup()+"的"+student.getName()+",听说你刚满"+student.getAge()+"岁。你家住在"+student.getAddress().getProvince()+student.getAddress().getCity();
    }


    @RequestMapping("arrayParam")
    public String arrayParam(String []  hobbys){
        System.out.println(Arrays.toString(hobbys));
        return  "朴实7组";
    }

    @RequestMapping("listParam")
    public String listParam(@RequestParam  List<String> hobbys){
        System.out.println(hobbys);
        return "宝宝84";
    }
}
